document.addEventListener("DOMContentLoaded", function() {
    // Проверяем, что мы на нужной странице
    if (
        window.location.pathname === "/pl/notifications/settings/my" || 
        window.location.pathname === "/pl/notifications/every-day-notification"
    ) {
        // Ищем все ссылки в меню
        const menuLinks = document.querySelectorAll("ul a");

        // Ищем нужную ссылку по адресу и изменяем её
        menuLinks.forEach(link => {
            if (link.getAttribute("href") === "/pl/notifications/../../user/my/profile") {
                link.setAttribute("href", "/profile");
            }
        });
    }
});

//Замена оригинальных ссылок на кастомные для страниц профиля и смены пароля
$(document).ajaxSuccess(function(event, xhr, settings) {
  if ( settings.url == "/cms/counters/menu" ) {
    var target = $('.gc-account-user-submenu-bar')[0];
    var observer = new MutationObserver(function(mutations) {
      $(".gc-account-user-submenu-bar li.menu-item-profile a").attr("href", "/profile");
      $(".gc-account-user-submenu-bar li.menu-item-change_password a").attr("href", "/changePassword");
      $(".gc-account-user-submenu-bar li.menu-item-chatium_app a").attr("href", "/chatium");
    }).observe(target, { attributes: false, childList: true, characterData: false, subtree: true });
  }
});